<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>用户添加</title>

    <!-- Bootstrap core CSS -->
    <link th:href="@{/webjars/bootstrap/4.3.1/css/bootstrap.css}" rel="stylesheet">
    <!-- Custom styles for this template -->
    <link th:href="@{/asserts/css/dashboard.css}" rel="stylesheet">
    <!-- 通知栏样式 -->
    <link th:href="@{/asserts/css/notificationBar.css}" rel="stylesheet">
</head>

<body>
<!-- 引入顶部栏 -->
<div th:replace="common/bar::topbar"></div>

<div class="container-fluid">
    <div class="row">
        <!-- 引入通知栏 -->
        <div th:replace="common/bar::NotificationBar"></div>

        <!-- 引入侧边栏 -->
        <div th:replace="common/bar::#sidebar(activeUri='userman')"></div>

        <main role="main" class="col-md-9 ml-sm-auto col-lg-10 pt-3 px-4">
            <h2 th:text="${edit_user != null} ? '用户修改' : '用户添加'"></h2>
            <h5 style="color: green">暂时只支持添加管理员，消费用户需要完善子账号（消费用户）功能。</h5>
            <hr>
            <input type="hidden" name="uid" th:if="${edit_user != null}" th:value="${edit_user.uid}">
            <div class="form-group">
                <label>账号</label>
                <input name="username" type="text" class="form-control" placeholder="账号，用户的唯一的登录验证标识符。"
                       th:value="${edit_user != null} ? ${edit_user.username}">
            </div>
            <div class="form-group">
                <label>密码</label><br/>
                <label><font color="red">注意：如果修改密码项，即是重置该用户的密码！</font></label><br/>
                <input name="password" type="text" class="form-control" placeholder="密码，登录时密码正确才能验证通过。">
            </div>

            <div class="form-group">
                <label>昵称</label>
                <input name="uinfo.nickname" type="text" class="form-control" placeholder="昵称，可以起个有意义的名字，以便以后知道用户是谁在使用。"
                       th:value="${edit_user != null} ? ${edit_user.uinfo.nickname}">
            </div>
            <div class="form-group">
                <label>联系电话</label>
                <input name="uinfo.phone" type="text" class="form-control" placeholder="联系电话，这一项便于以后找到用户本人。"
                       oninput="value=value.replace(/[^\d]/g,'')" th:value="${edit_user != null} ? ${edit_user.uinfo.phone}">
            </div>

            <div class="form-group">
                <label>冻结</label><br/>
                <label><font color="red">注意：冻结该用户该用户将无法再登录使用！</font></label><br/>
                <input type="radio" name="locked" value="false"
                       th:checked="${(edit_user != null && edit_user.locked == false) || (edit_user == null)} ? 'checked'" th:text="不冻结" />
                <input type="radio" name="locked" value="true"
                       th:checked="${edit_user != null && edit_user.locked == true} ? 'checked'" th:text="冻结" />
            </div>
            <div class="form-group">
                <label>启用</label><br/>
                <label><font color="red">注意：关闭该用户该用户登录将提示用户不存在！</font></label><br/>
                <input type="radio" name="enabled" value="true"
                       th:checked="${(edit_user != null && edit_user.enabled == true) || (edit_user == null)} ? 'checked'" th:text="启用" />
                <input type="radio" name="enabled" value="false"
                       th:checked="${edit_user != null && edit_user.enabled == false} ? 'checked'" th:text="关闭" />
            </div>

            <button type="submit" class="btn btn-primary" onclick="return userSaveOrUpdate()"
                    th:text="${edit_user != null} ? '更新' : '添加'"></button>

        </main>
        <br>
        <br>
        <br>
    </div>
</div>

<!-- 引入公共的js  -->
<div th:replace="common/js::js"></div>
<!-- 自定义的js -->
<script type="text/javascript" th:src="@{/asserts/js/user.js}" ></script>

</body>
</html>